//
//  myCell.m
//  MyProject
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "myCell.h"
#import "UIImageView+WebCache.h"


@implementation myCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create{
    
    self.viewL= [[UIView alloc] init];
    [self addSubview:self.viewL];
    [_viewL release];
    
    self.imageL = [[UIImageView alloc] init];
    [self.viewL addSubview:self.imageL];
    [_imageL release];
    
    self.lableTitleL = [[UILabel alloc] init];
    [self.viewL addSubview:self.lableTitleL];
    [_lableTitleL release];
    
    self.lableProviceL = [[UILabel alloc] init];
    self.lableProviceL.font = [UIFont systemFontOfSize:30 weight:30];
    self.lableProviceL.textAlignment = NSTextAlignmentCenter;
    [self.viewL addSubview:self.lableProviceL];
    [_lableProviceL release];
    
    self.lableNumL = [[UILabel alloc] init];
    self.lableNumL.textColor = [UIColor redColor];
    self.lableNumL.font = [UIFont systemFontOfSize:25 weight:25];
    self.lableNumL.textAlignment = NSTextAlignmentCenter;
    [self.viewL addSubview:self.lableNumL];
    [_lableNumL release];
    
    
    self.viewLW= [[UIView alloc] init];
    self.viewLW.backgroundColor = [UIColor grayColor];
    [self.viewL addSubview:self.viewLW];
    [_viewLW release];
    
}

- (void)layoutSubviews{
    
//        self.viewL.layer.borderWidth = 1;
    
//        self.imageL.layer.borderWidth = 1;
//
//        self.lableTitleL.layer.borderWidth = 1;
//    
//        self.lableProviceL.layer.borderWidth = 1;
//    
//        self.lableNumL.layer.borderWidth = 1;
//    
//        self.viewLW.layer.borderWidth = 1;
    
    self.viewL.frame = CGRectMake(self.frame.size.width / 37 * 3, self.frame.size.height / 66 * 2, self.frame.size.width / 37 * 31, self.frame.size.height / 66 * 62);
    
    self.imageL.frame = CGRectMake(0, 0, self.frame.size.width / 37 * 31, self.frame.size.height / 66 * 44);
    
    self.lableTitleL.frame = CGRectMake(0, self.frame.size.height / 66 * 44, self.frame.size.width / 37 * 31, self.frame.size.height / 66 * 12);
    self.lableProviceL.frame = CGRectMake(0, self.frame.size.height / 66 * 56, self.frame.size.width / 37 * 31 / 3 * 2, self.frame.size.height / 66 * 6);
    self.lableNumL.frame = CGRectMake( self.frame.size.width / 37 * 31/ 3 * 2, self.frame.size.height / 66 * 56, self.frame.size.width / 37 * 31 / 3 / 6 * 3 , self.frame.size.height / 66 * 6);
    self.viewLW.frame = CGRectMake( self.frame.size.width / 37 * 31/ 3 * 2, self.frame.size.height / 66 * 59, self.frame.size.width / 37 * 31 / 3 / 6 * 3, self.frame.size.height / 90);
    
}

- (void)setModel:(tableViewModel *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }

    [self.imageL sd_setImageWithURL:[NSURL URLWithString: self.model.image] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    self.lableTitleL.text = self.model.title;
    self.lableProviceL.text = self.model.price;
    self.lableNumL.text = self.model.market_price;
    
}





@end
